/**
 * Copyright (C) 2013 The yydorid-framework project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package net.yangying.androidframework.util;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @author YANGYING
 *
 * @date 2011-7-25
 */
public class DateUtils {

    public static String getFormateDateYMDHMS(String sourceformatType,String sourceStr)
    {
        
        //ע�⣺SimpleDateFormat���캯�����ʽ��strDate����ʽ�������
//        SimpleDateFormat simpleDateFormat=new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
//        SimpleDateFormat simpleDateFormat_new=new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
        SimpleDateFormat simpleDateFormat=new SimpleDateFormat(sourceformatType);
        SimpleDateFormat simpleDateFormat_new=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        //���벶���쳣
        try
        { 
         Date date=simpleDateFormat.parse(sourceStr);
//         System.out.println("date:"+date);
//         System.out.println("date2:"+simpleDateFormat_new.format(date));
         return simpleDateFormat_new.format(date);
        }
        catch(ParseException px)
        {
         px.printStackTrace();
        }
        return sourceStr;
    }
    public static String getFormateDateYMDHM(String sourceformatType,String sourceStr)
    {
        
        //ע�⣺SimpleDateFormat���캯�����ʽ��strDate����ʽ�������
//        SimpleDateFormat simpleDateFormat=new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
//        SimpleDateFormat simpleDateFormat_new=new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
        SimpleDateFormat simpleDateFormat=new SimpleDateFormat(sourceformatType);
        SimpleDateFormat simpleDateFormat_new=new SimpleDateFormat("yyyy-MM-dd HH:mm");
        //���벶���쳣
        try
        { 
         Date date=simpleDateFormat.parse(sourceStr);
//         System.out.println("date:"+date);
//         System.out.println("date2:"+simpleDateFormat_new.format(date));
         return simpleDateFormat_new.format(date);
        }
        catch(ParseException px)
        {
         px.printStackTrace();
        }
        return sourceStr;
    }
    public static String getFormateDateYMD(String sourceformatType,String sourceStr)
    {
        
        //ע�⣺SimpleDateFormat���캯�����ʽ��strDate����ʽ�������
//        SimpleDateFormat simpleDateFormat=new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
//        SimpleDateFormat simpleDateFormat_new=new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
        SimpleDateFormat simpleDateFormat=new SimpleDateFormat(sourceformatType);
        SimpleDateFormat simpleDateFormat_new=new SimpleDateFormat("yyyy-MM-dd");
        //���벶���쳣
        try
        { 
         Date date=simpleDateFormat.parse(sourceStr);
//         System.out.println("date:"+date);
//         System.out.println("date2:"+simpleDateFormat_new.format(date));
         return simpleDateFormat_new.format(date);
        }
        catch(ParseException px)
        {
         px.printStackTrace();
        }
        return sourceStr;
    }
    /**
     * @param args
     */
    public static void main(String[] args) {
        // TODO Auto-generated method stub

    }

}
